package com.wzh.design.strategy.demo2;

/**
 * @description: 策略模式
 * @author: WZH
 * @time: 2021/5/26 8:57
 */
/**
 * 主类：模拟鸭子
 */
public class StimulateDuck {
    public static void main(String[] args){
        //父类为Duck，屏蔽了超类的差别性
        Duck greenHeadDuck=new GreenHeadDuck();
        Duck redHeadDuck=new RedHeadDuck();

        greenHeadDuck.display();
        greenHeadDuck.Fly();
        greenHeadDuck.SetQuackBehavoir(new QuackBehavior() {
            @Override
            public void quack() {
                System.out.println("我会叫");
            }
        });
//        greenHeadDuck.Quack();



        greenHeadDuck.swim();

        System.out.println();
        System.out.println();

        redHeadDuck.display();
        redHeadDuck.Quack();
        redHeadDuck.swim();
        redHeadDuck.SetFlyBehavoir(new FlyBehavior() {
            @Override
            public void fly() {
                System.out.println("我会飞");
            }
        });
    }
}
